from rest_framework import serializers

from apps.goods.models import SKUImage, SKU


# 获取sku图片
class ImageSeriazlier(serializers.ModelSerializer):
    # 返回图片关联的sku的id值
    sku = serializers.PrimaryKeyRelatedField(read_only=True)

    class Meta:
        model = SKUImage
        fields = ('sku', 'image', 'id')

# 查询所有sku  只返回id 那么
class SkuSeriazlier(serializers.ModelSerializer):
    class Meta:
        model = SKU
        fields = ["name", 'id']